//
//  CYSimpleLoanM.m
//  CreditAddressBookEE
//
//  Created by LE on 16/2/17.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYSimpleLoanM.h"
#import "NSString+Extension.h"

@implementation CYSimpleLoanM

- (NSString *)statusStr {
    if (self.status.intValue == 3) {
        return @"该车辆已被申请悬赏";
    } else if (self.status.intValue == 2) {
        return @"已完成";
    } else {
        return @"悬赏中";
    }
}

- (NSString *)statusApplyStr {
    if (self.status.intValue == 3) {
        return @"该车辆已被申请悬赏";
    } else if (self.status.intValue == 1) {
        return @"对方已支付悬赏金，请注意查收";
    } else if (self.status.intValue == 2) {
        return @"对方已取消支付，可进行申诉";
    } else {
        return @"等待对方处理";
    }
}

- (NSString *)carNumberH {
    if (self.carNumber && !self.carNumber.isEmpty) {
        return [self hiddenStr:self.carNumber];
    }
    return @"***";
}

- (NSString *)companyNameH {
    if (self.companyName && !self.companyName.isEmpty) {
        return [self hiddenStr:self.companyName];
    }
    return @"***";
}

- (NSString *)companyPhoneH {
    if (self.companyPhone && !self.companyPhone.isEmpty) {
        return [self hiddenStr:self.companyPhone];
    }
    return @"***";
}

- (NSString *)nameH {
    if (self.name && !self.name.isEmpty) {
        return [self hiddenStr:self.name];
    }
    return @"***";
}

- (NSString *)certificateNumberH {
    if (self.certificateNumber && !self.certificateNumber.isEmpty) {
        return [self hiddenStr:self.certificateNumber];
    }
    return @"***";
}

- (NSString *)phoneH {
    if (self.phone && !self.phone.isEmpty) {
        return [self hiddenStr:self.phone];
    }
    return @"***";
}

- (NSString *)hiddenStr:(NSString *)str {
    if (str.length > 3) {
        return [NSString stringWithFormat:@"%@***%@", [str substringFromIndex:0 toIndex:2], [str substringFromIndex:(int)(str.length - 2) toIndex:(int)(str.length)]];
    }
    return [NSString stringWithFormat:@"%@***%@", [str substringFromIndex:0 toIndex:1], [str substringFromIndex:(int)(str.length - 1) toIndex:(int)(str.length)]];
}
@end
